package com.nf.xiaomi.web.controller;

import com.nf.mvc.ViewResult;
import com.nf.mvc.argument.RequestParam;
import com.nf.mvc.mapping.RequestMapping;
import com.nf.xiaomi.util.MinioUtils;

import java.io.InputStream;

import static com.nf.mvc.handler.HandlerHelper.file;

@RequestMapping("/file")
public class FileController {
    @RequestMapping("/download")
    public ViewResult download(@RequestParam(defaultValue = "firstbuckets") String bucket, @RequestParam(defaultValue = "1.jpg") String filename) {
        InputStream inputStream = MinioUtils.downloadStream(bucket, filename);
        return file(inputStream,filename);
    }

}
